package devices

import "yundian/internel/pkg/dingo"

// --------------------------- 设置默认初始值 ------------------------- //

type DeviceAttr func(model *DeviceModel)

type DeviceAttrs []DeviceAttr

func (attrFunc DeviceAttrs) Apply(m *DeviceModel) {
	for _, f := range attrFunc {
		f(m)
	}
}

func WithDeviceSn(deviceSn string) DeviceAttr {
	return func(m *DeviceModel) { m.DeviceSn = deviceSn }
}

func WithPlaceName(placeName string) DeviceAttr {
	return func(m *DeviceModel) { m.PlaceName = placeName }
}

func WithStatus(status uint8) DeviceAttr {
	return func(m *DeviceModel) { m.State = status }
}

func WithCreateAt(createAt dingo.Time) DeviceAttr {
	return func(m *DeviceModel) { m.CreateAt = createAt }
}

func WithUpdateAt(updateAt dingo.Time) DeviceAttr {
	return func(m *DeviceModel) { m.UpdateAt = updateAt }
}
